package day11demo;

import java.util.Random;
import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //输入字符串，随机打乱
        System.out.println("输入字符串，随机打乱");
        String str = sc.next();
        String randomString = changeString(str);
        System.out.println(randomString);
    }

    public static String changeString(String str){
        Random r = new Random();
        char[] arr = str.toCharArray();
        for (int i = 0; i < arr.length; i++) {
            int len = r.nextInt(arr.length);
            char c = arr[i];
            arr[i] = arr[len];
            arr[len] = c;
        }
        return new String(arr);
    }

}
